package com.hdoit.kylin.logical.studentManager.dao.impl;
import java.util.List;

import org.springframework.stereotype.Component;

import com.tennetcn.common.dao.base.IFinderExpression;
import com.tennetcn.common.dao.base.impl.SuperDao;
import com.tennetcn.common.message.PagerModel;
import com.tennetcn.common.utils.FinderExpressionFactory;
import com.hdoit.kylin.logical.experiment.model.Experiment;
import com.hdoit.kylin.logical.studentManager.dao.IExperimentExcelDao;
import com.hdoit.kylin.logical.studentManager.model.ExperimentExcel;
import com.hdoit.kylin.logical.viewmodel.ExperimentExcelSearch;
/**
* @author admin
* @email
* @createtime 2017年07月21日 14:17:57
* @comment
*/
@Component
public class ExperimentExcelDaoImpl extends SuperDao<ExperimentExcel> implements IExperimentExcelDao{
	
	public int queryCountByExperimentId(ExperimentExcelSearch search,String experimentId){
		IFinderExpression finderExpression = FinderExpressionFactory
				.createExpression();
		finderExpression.addBody("select count(excelId) from",ExperimentExcel.class)
						.andWhere("experimentId = #{experimentId}")
						.setParam("experimentId", experimentId);
		return queryCount(finderExpression, search);
	}
	
	public int queryCountByExperimentId(String experimentId){
		IFinderExpression finderExpression = FinderExpressionFactory
				.createExpression();
		finderExpression.addBody("select count(excelId) from",ExperimentExcel.class)
						.andWhere("experimentId = #{experimentId}")
						.setParam("experimentId", experimentId);
		return queryCount(finderExpression);
	}
	
	public List<ExperimentExcel> queryListByExperimentId(ExperimentExcelSearch search, PagerModel pagerModel,
			String experimentId){
		IFinderExpression finderExpression = FinderExpressionFactory.createExpression();
		finderExpression.select("experimentExcel.*")
						.from(ExperimentExcel.class,"experimentExcel")
						.leftJoin(Experiment.class, "experiment")
						.on("experimentExcel.experimentId", "experiment.experimentId")
						.andWhere("experimentExcel.experimentId=#{experimentId}")
						.setParam("experimentId", experimentId);
		finderExpression.addOrderInfoList(getOrderInfoList());
		return queryList(finderExpression,search,pagerModel);
	}

	@Override
	public List<ExperimentExcel> queryListByExperimentId(PagerModel pagerModel,
			String experimentId) {
		IFinderExpression finderExpression = FinderExpressionFactory.createExpression();
		finderExpression.select("experimentExcel.*")
						.from(ExperimentExcel.class,"experimentExcel")
						.leftJoin(Experiment.class, "experiment")
						.on("experimentExcel.experimentId", "experiment.experimentId")
						.andWhere("experimentExcel.experimentId=#{experimentId}")
						.setParam("experimentId", experimentId);
		finderExpression.addOrderInfoList(getOrderInfoList());
		return queryList(finderExpression,pagerModel);
	}
	
}